package it.hopeless.jee6.scheduling;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ejb.Schedule;
import javax.ejb.Stateless;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * User: frico
 * Date: Feb 13, 2010
 * Time: 1:26:51 AM
 */
@Stateless
public class SchedulerService {
    private static final Logger logger = LoggerFactory.getLogger(SchedulerService.class);
    private String time = "00:00:00";

    @Schedule(minute="2", hour ="*")
    private void doEverySecondMinute() {
        logger.debug("I'm scheduled to print it every second minute of each hour");
    }

    @Schedule(second="*/10", minute = "*", hour = "*")
    private void changeEveryTenSeconds() {
        time = new SimpleDateFormat("hh:mm:ss").format(new Date());
    }
    
    public String getTime() {
        return time;
    }
}
